package com.xframe.xdal.core.model.sqlbuilder.factory;


import com.xframe.xdal.core.constant.DataSourceTypeEnums;
import com.xframe.xdal.core.model.sqlbuilder.BaseSqlBuilder;
import com.xframe.xdal.core.model.sqlbuilder.SqlBuilderFactory;
import com.xframe.xdal.core.model.sqlbuilder.proc.page.MySqlPageSearchSqlBuilder;
import com.xframe.xdal.core.model.sqlbuilder.proc.page.OraclePageSearchSqlBuilder;

/**
 * 功能描述:分页查询sql构造工厂
 *
 * @author xufeng
 * @version 1.0
 * @date 2022-09-26
 */
public class PageSearchSqlBuilderFactory extends SqlBuilderFactory {
    @Override
    public BaseSqlBuilder create(DataSourceTypeEnums dataSourceTypeEnums) {
        SearchSqlBuilderFactory searchSqlBuilderFactory = new SearchSqlBuilderFactory();
        BaseSqlBuilder baseSqlBuilder = null;
        BaseSqlBuilder searchSqlBuilder = searchSqlBuilderFactory.create(dataSourceTypeEnums);
        switch (dataSourceTypeEnums){
            case MySql:
                baseSqlBuilder = new MySqlPageSearchSqlBuilder(searchSqlBuilder);
                break;
            case Oracle:
                baseSqlBuilder = new OraclePageSearchSqlBuilder(searchSqlBuilder);
                break;
        }
        return baseSqlBuilder;
    }
}
